package com.metka.volidata.util;

import java.lang.reflect.Method;

/**
 * @Author: Metka499
 * @Description:
 * @CreateTime: 2020/7/6 17:18
 */
public class ReflectUtils {

    /**
     * 通过属性获得 get方法
     * @param clazz
     * @param field
     * @return
     */
    public static Method getterMethod(Class<?> clazz, String field) throws NoSuchMethodException {
        //先解析get方法名
        StringBuilder sb = new StringBuilder();
        String getterMethodName = sb.append("get").append(field.substring(0,1).toUpperCase()).append(field.substring(1)).toString();
        return clazz.getMethod(getterMethodName);
    }


}
